package com.vfa.fishing.common;


import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;

public class Utils 
{
	
	public static MediaPlayer loadResInMediaPlayer(Context context,int res,MediaPlayer mp)
	{
		if(mp !=null)
		{
			mp.reset();
			mp.release();
		}
		mp = MediaPlayer.create(context, res);
		return mp;
	}
	
	public static void playMediaPlayer(MediaPlayer mp,boolean isLoop)
	{		
		mp.start();				
		mp.setLooping(isLoop);
	}
	
	public static void stopMediaPlayer(MediaPlayer mp)
	{
		mp.stop();
	}
	
	public static SoundPool initSoundPool(SoundPool soundpool)
	{		
		soundpool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);			
		return soundpool;
	}
	
	public static int loadSoundPool(SoundPool soundpool,Context context,int res,int priority)
	{
		return soundpool.load(context, res, priority);
	}
	
	public static void playSoundPool(Context context,SoundPool soundpool,int res,int priority,int loop)
	{
		AudioManager mgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
		int streamVolume = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
//		soundpool.play(soundPoolMap.get(sound), streamVolume, streamVolume, 1, 0, 1f);		
		soundpool.play(res, 50, 50, priority, loop, 1f);
	}
	
	public static void stopSoundPool(SoundPool soundpool,int resId)
	{					
		soundpool.stop(resId);
	}
}
